package com.heima.behavior.controller.v1;

import com.heima.behavior.service.*;
import com.heima.model.behavior.dtos.*;
import com.heima.model.common.dtos.ResponseResult;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@Api("文章的点赞实现")
@RequestMapping("/api/v1")
public class ApLikesBehaviorController {
    @Autowired
    ApBehaviorLikesService apBehaviorLikesService;

    @Autowired
    ApReadBehaviorService apReadBehaviorService;


    @Autowired
    ApUnlikeBehaviorService apUnlikeBehaviorService;

    @Autowired
    ApCollectionBehaviorService apCollectionBehaviorService;

    @ApiOperation("点赞或取消点赞")
    @PostMapping("/likes_behavior")
    public ResponseResult like(@RequestBody @Validated LikesBehaviorDTO dto) {
        return apBehaviorLikesService.LikesOrDislikes(dto);
    }


    @ApiOperation("阅读")
    @PostMapping("/read_behavior")
    public ResponseResult readBehavior(@RequestBody ReadBehaviorDTO dto) {
        return apReadBehaviorService.readBehavior(dto);
    }

    @ApiOperation("喜欢不喜欢")
    @PostMapping("/un_likes_behavior")
    public ResponseResult unlikeBehavior(@RequestBody @Validated UnLikesBehaviorDTO dto){
        return apUnlikeBehaviorService.unlikeBehavior(dto);
    }


    @ApiOperation("收藏")
    @PostMapping("/collection_behavior")
    public ResponseResult collectArticle(@RequestBody CollectionBehaviorDTO dto){
        return apCollectionBehaviorService.collectBehavior(dto);
    }

}
